package opera;

import Book.BookList;
import Book.book;

import java.util.Scanner;

/**
 * @Author: shark爱吃辣椒
 * @Date: 2022-19-14:46
 * @Description:
 */
public class Return implements IOpera{
    @Override
    public void work(BookList bookList) {
        System.out.println("归还图书");

        System.out.println("请输入要归还图书的名字：");
        Scanner sca = new Scanner(System.in);
        String name = sca.nextLine();
        int bookslength  = bookList.getBooksnum();
        for (int i = 0; i < bookslength; i++) {
            book book = bookList.getbook(i);
            if(book.getName().equals(name)){
                book.setBorrowed(false);
                System.out.println("归还成功");
                return;
            }
        }

        System.out.println("图书没有找到");
    }
}
